FROM golang:1.21 AS build-stage

WORKDIR /app

COPY go.mod go.sum ./
RUN GOPROXY=https://goproxy.io,direct go mod download

COPY *.go ./
RUN CGO_ENABLED=0 GOOS=linux go build -o /backend

# Deploy the application binary into a lean image
FROM golang:1.21 AS build-release-stage
WORKDIR /
COPY --from=build-stage /backend /backend
EXPOSE 8080

ENTRYPOINT ["/backend"]
